package com.tshopping.dao;

import com.tshopping.bean.Level;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
public interface LevelDao {

    @Insert("insert into goods_level (name,parent) values (#{name},#{parent})")
    boolean insertLevel(@Param("name")String name, @Param("parent")int parent);

    @Select("select * from goods_level where parent = #{parent}")
    ArrayList<Level> selectLevelByParent(@Param("parent")int parent);

    @Update("update goods_level set name = #{name},parent = #{parent} where id = #{id}")
    boolean updateNameById(@Param("name")String name, @Param("parent")int parent, @Param("id")int id);

    @Delete("delete from goods_level where id = #{id}")
    boolean deleteLevelById(@Param("id")int id);

    @Select("select * from goods_level")
    ArrayList<Level> selectAllLevels();

    @Select("select * from goods_level where id=#{id}")
    Level selectLevelByLevelId(@Param("id") int id);

}
